﻿using System;

namespace Hx.Infrastructure.Exceptions
{
    public class RequestException : ErrorCodeException
    {
        /// <summary>
        ///     创建一个请求异常
        /// </summary>
        /// <param name="requestErrorCode">请求错误代码</param>
        /// <param name="type">请求类型</param>
        public RequestException(int requestErrorCode, RequestType type)
            : this(requestErrorCode, type, null, null)
        {
        }

        /// <summary>
        ///     创建一个请求异常
        /// </summary>
        /// <param name="requestErrorCode">请求错误代码</param>
        /// <param name="type">请求类型</param>
        /// <param name="requestContent">请求内容</param>
        public RequestException(int requestErrorCode, RequestType type, string requestContent)
            : this(requestErrorCode, type, null, null)
        {
            RequestContent = requestContent;
        }

        /// <summary>
        ///     创建一个请求异常
        /// </summary>
        /// <param name="requestErrorCode">请求错误代码</param>
        /// <param name="type">请求类型</param>
        /// <param name="errorMsg"></param>
        /// <param name="innerException">请求内容</param>
        public RequestException(int requestErrorCode, RequestType type, string errorMsg, Exception innerException)
            : base(0x00000010, requestErrorCode, errorMsg, innerException)
        {
            Type = type;
        }

        /// <summary>
        ///     请求类型
        /// </summary>
        public RequestType Type { get; private set; }

        /// <summary>
        ///     请求内容
        /// </summary>
        public string RequestContent { get; set; }
    }

    /// <summary>
    ///     请求类型
    /// </summary>
    public enum RequestType
    {
        /// <summary>
        ///     位置请求
        /// </summary>
        Unknown = 0,

        /// <summary>
        ///     GET
        /// </summary>
        Get = 1,

        /// <summary>
        ///     POST
        /// </summary>
        Post = 2,

        /// <summary>
        ///     PUT
        /// </summary>
        Put = 3,

        /// <summary>
        ///     DELETE
        /// </summary>
        Delete = 4
    }
}